cmake_minimum_required(VERSION 3.10)
project(SQlite3MC-Cpp)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/bin)
if(WIN32)
    set(SQLite3MC_DIR "D:/App/sqlite3mc-2.1.1-sqlite-3.49.2-icu-win64")
elseif(LINUX)
    
endif()

include_directories(${SQLite3MC_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

file(GLOB EXAMPLE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/examples/*.cpp")

foreach(EXAMPLE_SOURCE IN ITEMS ${EXAMPLE_SOURCES})
    get_filename_component(EXAMPLE_NAME ${EXAMPLE_SOURCE} NAME_WE)
    set(EXAMPLE_EXECUTABLE example-${EXAMPLE_NAME})

    add_executable(${EXAMPLE_EXECUTABLE} ${EXAMPLE_SOURCE})

    target_link_libraries(${EXAMPLE_EXECUTABLE} PRIVATE 
        ${SQLite3MC_DIR}/dll/sqlite3mc_icu_x64.lib
    )

    if(WIN32)
        # 构建后复制 DLL 到可执行文件所在目录
        add_custom_command(TARGET ${EXAMPLE_EXECUTABLE} POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_if_different
                "${SQLite3MC_DIR}/dll/sqlite3mc_icu_x64.dll"
                $<TARGET_FILE_DIR:${EXAMPLE_EXECUTABLE}>
        )
    endif()
endforeach()


